package controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.PathVariable;
@Controller
public class HelloController {

    //传参方法一
//    @GetMapping("/hi")
//    @ResponseBody
//    public String hi(String name) {
//        System.out.println("name==>" + name);
//        return "hello " + name + "!";
//    }

    //传参方法二
//    @GetMapping("/hi/{name}")
//    @ResponseBody
//    public String sayhi(@PathVariable String name) {
//        System.out.println("name==>" + name);
//        return "hello " + name + "!";
//    }

    //传参方法三
    @GetMapping("/hei")
    @ResponseBody
    public String sayhei(@RequestParam("username")  String name) {
        System.out.println("name==>" + name);
        return "hello " + name + "!";
    }
}
